<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmTitle">
        <p:growl id="msgs" showDetail="false"/>
        <h:panelGrid columns="2" cellpadding="1">
            <h:outputText value="#{msgs.statusTituloLista}" styleClass="fontTitle"/>
        </h:panelGrid>
    </h:form>
        
    <h:panelGrid columns="2" width="100%">
        
        <h:form id="frmSearch">
            
            <h:panelGrid columns="3">
                
                <p:commandLink id="refreshTable" actionListener="#{statusMB.atualizarTabela}" title="#{msgs.btnAtualizar}"  update=":frmDataTable:tbl" >
                    <h:graphicImage value="img/refresh.png" style="border: 0" />
                </p:commandLink>
                    
                <p:inputText id="txtBusca" value="#{statusMB.busca}" size="35" />
                <p:commandButton id="btnSearch" value="#{msgs.btnBuscar}" alt="#{msgs.btnBuscar}" title="#{msgs.btnBuscar}" actionListener="#{statusMB.buscar}" icon="ui-icon ui-icon-search" update=":frmDataTable:tbl"/>
                    
            </h:panelGrid>
                
        </h:form>
            
    </h:panelGrid>

    <h:form id="frmDataTable">

        <p:fieldset legend="#{msgs.statusLgdLista}">

            <h:panelGrid width="100%">            

                <p:dataTable id="tbl" var="tbl" paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                             emptyMessage="#{msgs.msgTabelaVazia}" value="#{statusMB.lsstatus}">
                    <f:facet name="header">
                        <h:outputText value="#{msgs.statusTblTitulo}"/>                    
                    </f:facet>
                       
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.descricao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.descricao}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colDtCriacao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.dtcriacao}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colStatus}"/>
                        </f:facet>
                        <h:outputText value="#{statusMB.strStatusLabel(tbl.status)}"/>
                    </p:column>
                     
                    <p:column style="width:160px">
                        <p:commandButton id="btnEditar"  alt="#{msgs.btnEditar}" title="#{msgs.btnEditar}" icon="ui-icon ui-icon-pencil" action="#{statusMB.editar}" ajax="false" >
                            <f:param id="idstatus" name="idstatus" value="#{tbl.id}"/>
                        </p:commandButton>
                        <p:commandButton id="btnExcluir" alt="#{msgs.btnExcluir}" title="#{msgs.btnExcluir}" icon="ui-icon ui-icon-close" oncomplete="cfmDlgExcluir.show()" actionListener="#{statusMB.selecionarRegistro(tbl)}" update=":frmExcluir"/>
                    </p:column>
                   
                </p:dataTable>
            
            </h:panelGrid>
        </p:fieldset>
    </h:form>
    
    <h:form id="frmExcluir">

        <p:confirmDialog id="confirmDialogExcluir" header="#{msgs.statusDlgTituloExcluir}" message=" #{msgs.dlgMsgExcluir} #{statusMB.statusselecionado.descricao} ?"
                         width="300" height="60" severity="alert" widgetVar="cfmDlgExcluir">

            <p:commandButton value="#{msgs.btnSim}" oncomplete="cfmDlgExcluir.hide()" alt="#{msgs.btnSim}" title="#{msgs.btnSim}" actionListener="#{statusMB.excluir}"
                             update=":frmTitle:msgs,:frmDataTable:tbl"/>
            <p:commandButton value="#{msgs.btnNao}" onclick="cfmDlgExcluir.hide()" alt="#{msgs.btnNao}" title="#{msgs.btnNao}" type="button"/>

        </p:confirmDialog>

    </h:form>
        
</html>

